<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8">
		<title>轮播编辑页面</title>
		<link rel="stylesheet" href="__ADMIN_PATH__/component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>轮播图片</label>
						<div class="layui-input-block">
							<button type="button" class="pear-btn pear-btn-primary pear-btn-sm plug-file-upload-submit" data-view-tag="ul.slide-images_url-view">
								<i class="layui-icon">&#xe67c;</i>上传图片
							</button>
							<ul class="plug-file-upload-view slide-images_url-view" data-form-name="images_url" data-max-number="1" data-delete="1" data-dialog-type="images">
								{if condition="!empty($info['images_url'])"}
								    <li>
								    	<input type="hidden" name="images_url" value="{$info['images_url']}" />
								    	<img src="{$info['images_url']}" height="100" />
								    	<i class="layui-icon title-nav-remove">&#x1006;</i>
								    </li>
								{/if}
							</ul>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">排序</label>
						<div class="layui-input-block">
							<input type="number" name="sort" autocomplete="off" placeholder="请输入排序" class="layui-input" value="{$info['sort'] ?? ''}" />
						</div>
					</div>

				</div>
			</div>

			<div class="bottom">
				<div class="button-container">
					<input type="hidden" name="id" value="{$info['id'] ?= $info['id']}" />
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="slide">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="__ADMIN_PATH__/component/layui/layui.js"></script>
		<script src="__ADMIN_PATH__/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery', 'popup', 'loading'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				var popup = layui.popup;
				let loading = layui.loading;

				/**
				 * 表单提交
				 */
				form.on('submit(slide)', function(data) {
					$.ajax({
						url:"{:url('Slide/save')}",
						type:"POST",
						dataType:"JSON",
						data:data.field,
						beforeSend: function () {
							loading.Load(1, "");
		                },
		                complete: function () {
		                	loading.loadRemove();
		                },
		                success:function(res)
		                {
		                	if(res.code == 0)
		                	{
		                		//正常业务
		                		popup.success(res.msg, function(){
		                			var index = parent.layer.getFrameIndex(window.name);
		                			parent.location.reload();
		                			parent.layer.close(index); //再执行关闭
	                        	});
		                	}else
		                	{
		                		//业务异常
		                		popup.warning(res.msg);
		                	}
		                },
		                error:function()
		                {
		                	loading.loadRemove();
		                	popup.failure('服务器错误');
		                }
		            });
		            return false;
		        });
		    });
		</script>
		<style type="text/css">
			.plug-file-upload-view li
			{
				display: inline;
			}
		</style>
		{include file="publics/ueditor" /}
	</body>
</html>